package action;

import helpers.ClientRequest;
import play.libs.F.Promise;
import play.mvc.Action;
import play.mvc.Http.Context;
import play.mvc.SimpleResult;

public class BeforeAfterAction extends Action.Simple {
	private void before(Context ctx) { 
	    System.out.println("BEFORE ACTION");
	    
	    ClientRequest.setCurrent();	    
	}

	private void after(Context ctx) { 
	} 
	  
	@Override
	public Promise<SimpleResult> call(Context ctx) throws Throwable{
		try {
			before(ctx);
			Promise<SimpleResult> result = delegate.call(ctx); // This part calls your real action method 
			after(ctx);
			return result;
	    } 
		catch (RuntimeException e) {
	      throw e;
	    } 
		catch (Throwable t) {
	      throw new RuntimeException(t);
	    }
	  } 
}
